home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 29.6 KB | 827 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: TargetCheck.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: KTA, KL, ML, GS et al
- #
- # Copyright: © 1993-1995 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.1.3> 11/16/95 ML Added SystemFileInfo()
- # <1.1.2> 4/11/95 KTA Moved IsPowerPC() from Gestalt.lib and created a new task
- # IsSystem7().
- # <1.1.1> 3/3/95 ML RecordGetAboutThisMacintosh() - comment out system size until
- # MemoryMonitor bug is fixed, move all memory size results to TCS
- # Num field
- # <1.1.0> 2/16/95 KTA MachineState() - Readded MonitorInfo
- # .0.1112> 2/15/95 ML GetRomBuild() - if fail, return string instead of undefined.
- # .0.1111> 1/31/95 KTA GetROMBuild() - Print error message when old version of
- # MemoryMonitor
- # .0.1110> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher().
- # 1.0.119> 1/16/95 KTA MachineState() - Added pUseXTools.
- # 1.0.118> 1/16/95 KTA MachineState() - added OSVersion, and ROMBuild, GetROMBuild() -
- # created
- # 1.0.117> 1/11/95 KTA RecordMonitorInfo() - Changed it so doesn't call MachineState()
- # and simplified.
- # 1.0.116> 1/11/95 KTA MachineState() - Removed gestalt support for VU 2.0.1 (two
- # shorts), Removed FormLongNumber() and all dependancies
- # on the MathTool.Lib and MathTool.
- # 1.0.115> 12/13/94 KTA
- # 1.0.114> 12/12/94 ML Remove gTestCaseLoggingMethod, revise filetool calls to
- # _Filetool calls, revise MemoryMonitor calls to _MemoryMonitor
- # calls, remove Filetool.vulib and MemoryMonitor.vulib from
- # library declarations.
- # 1.0.113> 12/12/94 ML Removed gLogLevel, replace w/gDisableAllLogging
- # 1.0.112> 12/5/94 ML Added Exception Handling support
- # 1.0.111> 11/3/94 KTA Refixed some old code that got back into Restart() - now
- # selecting Restart menuitem by ordinality.
- # 1.0.110> 9/21/94 ML Revise gestalt calls in MachineState() for VU 2.1
- # support, ProfileApplication() - Check globals
- # gAddSuiteInfoFieldsRE and gAdditionalSuiteInfoFT before
- # resetting
- # <1.0.19> 9/19/94 KTA Restart() -Made several fixes to support Powertalk whixh takes
- # longer to reboot (result = No_Error).
- # <1.0.18> 7/18/94 KTA Restart() - Added support for PowerBooks - they add a sleep
- # menuitem.
- # <1.0.17> 5/10/94 ML Check for modal before Profiling application
- # <1.0.16> 4/13/94 KTA Changed the name of RecordRamFootPrint() to
- # RecordGetAboutThisMacintosh().
- # <1.0.15> 4/11/94 KTA MachineState() - Removed an instance of SystemArch that hadn't
- # been removed.
- # <1.0.14> 4/8/94 ML Removed hanging TCSEnd() and revised params for TCSStart
- # and end in RecordGetAboutThisMacintosh().
- # in RecordGetAboutThisMacintosh().
- # <1.0.13> 3/29/94 KTA Restart() - Use ordinality instead of strings.
- # <1.0.12> 3/28/94 KTA Added <Tool>Operations.Lib and moved some tasks into them.
- # <1.0.11> 3/23/94 KTA Added marks
- # <1.0.10> 3/23/94 KTA MachineState() - Removed System Arch.
- # <1.0.9> 3/19/94 ML Revised RecordGetAboutThisMacintosh for appname in TCSEnd
- # <1.0.8> 3/17/94 ML added ProfileApplication()
- # <1.0.7> 3/16/94 ML moved non-gestalt tasks here from gestalt.lib, added
- # RecordGetAboutThisMacintosh() and RecordMonitorInfo() tasks.
- # <1.0.6> 9/29/93 KTA Removed TargetCheck(), OpenCDEV(which), CloseCDEV(which),
- # SwitchAddressing(value) SwitchVM(state), SwitchFS(state),
- # SwitchCache(state) because there were buggy and no one
- # was(could) using them
- # <1.0.5> 8/25/93 KTA TargetCheck() - BugFix where turning VM off wasn't handled
- # properly.
- # <1.0.4> 7/15/93 KTA Updated References to tasks in Gestalt.lib whos names were
- # changed. Took out code to turn VM down - SwitchVM(). Took out
- # releasetarget prior to restart if restartNecessary -
- # TargetCheck(). Removed checks for Undef, before checking state.
- # <1.0.3> 6/8/93 NAGA Unmark tasks that are not published
- # <1.0.2> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries 'Output.Lib', "MemoryMonitorOperations.lib",
- "Globals.Lib", "UserInterface.Lib", "TCS.Lib", "Gestalt.Lib", "OnTarget.Lib",
- "OnTargetOperations.Lib", "FileToolOperations.Lib",
- "ExceptionHandling.Lib","String.Lib";
-
- #########################################################################
- # SystemFileInfo( pFileType )
- #========================================================================
- # Author: ML
- # Description: Provides info on the targets system files
- # Parameters: pFileType: 'extn' - info on extensions
- # 'ctrl' - info on control panels
- # 'macs' - info on system folder root files
- # Returns: 0 - Failure
- # List of list of file name, list of type, version, i.e.
- # {
- # { 'PrintMonitor',{ 'APPL','7.1.2' } },
- # ' EM Extension',{ 'INIT','3.0' } }, ...
- # }
- #
- # Examples: SystemFileInfo('extn');
- # Assumptions: Finder Scripting Extension, program linking, guest access
- # must be installed and enabled on target for this task
- # to succeed.
- # Notes: List returned is optimized for obtaining info based on file
- # name, i.e. assoc ("Monitors", SystemFileInfo( 'ctrl' ));
- # will return {type, version} of the Monitors cDev.
- #========================================================================
- # History:
- # ML 11/16/95 created
- #########################################################################
- Task SystemFileInfo( pFileType )
- begin
- returnval := 0;
- switch pFileType
- begin
- case 'extn':
- folderName := 'extensions';
- case 'ctrl':
- folderName := 'control panels';
- case 'macs':
- folderName := 'system';
- default:
- begin
- logstr("!@#$% - pFileType must be either 'extn', 'ctrl', or 'macs'." );
- return returnval;
- end;
- end;
- #println folderName;
- getFileInfoScript :=
- 'tell application "Finder" of machine "' + "{global gMachineName}" + '"
- set namelist to {name} of files in ' + "{folderName}" + ' folder
- set typelist to {file type} of files in ' + "{folderName}" + ' folder
- try
- set verslist to {version} of files in ' + "{folderName}" + ' folder
- set theList to namelist & typelist & verslist
- on error
- set verslist to {}
- repeat with n in files in ' + "{folderName}" + ' folder
- try
- set currlist to {version} of n
- on error
- set currlist to {"n/a"}
- end try
- set verslist to verslist & currlist
- end repeat
- set theList to namelist & typelist & {verslist}
- end try
- return theList
- end tell';
- #println getFileInfoScript;
- fileInfoList := applescriptstring(getFileInfoScript);
- if (fileInfoList[1] = 0)
- begin
- fileInfoList := fileInfoList[2];
- #println fileInfoList;
- numItems := card(fileInfoList[1]);
- #println numItems;
- typeVersList := {};
- theList := {};
- for i := 1 to numitems
- begin
- typeVersList := {fileInfoList[2][i], fileInfoList[3][i]};
- theList := insert({fileInfoList[1][i], typeVersList},
- card(theList) + 1, theList);
- end;
- returnval := theList;
- end;
- else
- LogStr("!@#$% - Problem with Applescript. Is Finder Scripting Extension
- installed, Program linking and Guest access enabled?");
- return returnval;
- end;
-
- #########################################################################
- # Restart()
- #========================================================================
- # Author: RV
- # Description: Restarts and reaquires Targets
- # Parameters: None
- # Returns: 1 - Success
- # 0 - Failure
- # Examples: Restart();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 7/14/93 Changed some of the logging and added global restartNecessary := 0;
- # KTA 3/29/94 SelectMenuItem by Ordinality, longer wait.
- # KTA 7/18/94 Added support for PowerBook - they add a sleep menuitem.
- # KTA 9/19/94 Made several fixes to support Powertalk whixh takes longer to
- # reboot (result = No_Error).
- # ML 11/29/94 Added Exception Handling support
- # ML 12/12/94 Removed gLogLevel, replace w/gDisableAllLogging
- #########################################################################
- TASK Restart(Time_to_restart := 25)
- begin
- global gDisableAllLogging;
- No_Error := 0;
- Target_Not_Found := 3; #error codes returned by acquireTarget/releaseTarget
- Target_Failure := 1; #error codes returned by acquireTarget/releaseTarget
-
- try match[application t:?AppTitle];
- catch theError
- ExceptionDispatcher(theError);
- if not(AppTitle = 'Finder')
- _select([menuItem t:'Finder']!,1);
-
- theMenuItems := _collect([menuItem m:[menu o:6]]!,1);
- WhichMenu := Card(theMenuItems)-1; # Restart menuitem is second from the bottom in the Special menu
- # except on Powerbooks which add two menuitems including - 'Sleep'
-
- try match[target t:?target_name z:?target_zone]; # Get the target name and zone through unification
- catch theError
- ExceptionDispatcher(theError);
- global restartNecessary := 0;
-
- theMI := _match ([MenuItem o:WhichMenu m:[menu o:6]]!,1); # Test to see if PowerBook menuitems were added
- if(theMI.t = '-') and (theMI.e = false)
- WhichMenu := WhichMenu-2;
-
- _Select ([MenuItem o:WhichMenu m:[menu o:6]]!,1); # Select the Restart MenuItem
-
- if not (gDisableAllLogging)
- begin
- println "Selected the 'Restart' menu item";
- Println "Rebooting CPU";
- end;
-
- # Need a save document dialog handler
-
- result := releaseTarget(); # Release target so VU realizes that the target has been lost.
-
- if (result <> Target_Failure) # Released okay
- begin
- if not (gDisableAllLogging)
- Println "Released target successfully";
-
- wait(Time_to_restart); # Short wait to allow machine to boot.
-
- #do an acquire with the same old target name and zone address
- result := acquireTarget(target_name, target_zone);
- counter := 1;
- while not (result = No_Error) and (counter <= 20)# Keep trying until target is found or some other error is reported
- begin
- counter := counter +1;
- wait(Time_to_restart); # Wait
- result := acquireTarget(target_name, target_zone);
- end;
-
- if (result = No_Error) # Reaquired target successfully
- begin
- # Need to wait till all inits get loaded.
- while not _matchBoolean([menu]); # Match menu may not be a long enough wait
- LogStr("Reaquired target successfully",4);
- return (1);
- end;
- else # Couldn't reaquire target successfully
- begin
- LogStr("!@#$% Couldn't aquire target",1);
- Exit;
- end;
- end;#if released ok
- else
- begin
- LogStr("!@#$% Couldn't release target",1);
- return(0); #error couldn't release target
- end;
- end; # Restart()
-
-
- #########################################################################
- # MatchApplication(logMe,UpdateAppTitle)
- #========================================================================
- # Author: KTA
- # Description: This routine will match the current Application and,
- # if the logMe parameter is 1, will log the current
- # application name by passing it to LogStr(). If a
- # parameter is not passed, the default behavior will
- # log the application's title. This routine will also
- # set the global gAppTitle to the application's title.
- # Output appears in the following format:
- # The current application is "Finder"
- # Parameters: logMe - 1 to print the current application's title
- # 0 not to print the application's title
- # UpdateAppTitle - 1 to update the global AppTitle
- # - 0 not to update global AppTitle
- # Return Value: string holding current application's title
- # Examples: MatchApplication();
- # Assumptions: there is an active application
- #========================================================================
- # History:
- # ML 11/29/94 Added Exception Handling support
- #########################################################################
- TASK MatchApplication(logMe := 1, UpdateAppTitle :=1)
- begin
- try match[application t:?theAppTitle];
- catch theError
- ExceptionDispatcher(theError);
- if (UpdateAppTitle)
- global gAppTitle := theAppTitle; #to Verify App
-
- if (logMe)
- LogStr("The current application is '{theAppTitle}'");
-
- return(theAppTitle);
- end; # MatchApplication()
-
-
- #########################################################################
- # RecordGetAboutThisMacintosh(pPhysicalRAM, pLogicalRAM, pLargestUnusedBlock, pSystemSize)
- #========================================================================
- # Author: KTA
- # Description: Makes the calls to create TCSes which record the
- # current Physical RAM, logical RAM, largest unused block, and system
- # size to a Phoenix output file.
- # Parameters: pPhysicalRAM - 1 Report PhysicalRAM size.
- # - 0 Don't report PhysicalRAM size.
- # pLogicalRAM - 1 Report LogicalRAM size.
- # - 0 Don't report LogicalRAM size.
- # pLargestUnusedBlock - 1 Report LargestUnusedBlock size.
- # - 0 Don't report LargestUnusedBlock size.
- # pSystemSize - 1 Report system size.
- # - 0 Don't report system size.
- # pAppName - string name of app to get memory size of
- # - 0 Don't report application size.
- # Returns: {list} - List of sizes you've requested
- # 0 - unsuccessful
- # Examples: RecordGetAboutThisMacintosh();
- # Assumptions:
- #========================================================================
- # History:
- # KTA 3/08/94 Created
- # ML 3/16/94 Genericized for SPEC S&L
- # ML 3/19/94 Added pAppname
- # KTA 3/28/94 Reverted back to older task as returnVal should be pass or fail
- # ML 4/08/94 Removed hanging TCSEnd, revised TC id's to use constants
- # ML 12/12/94 Revised to call _MemoryMonitor
- # ML 3/3/95 comment out system size until MemoryMonitor bug is fixed
- # move all memory size results to TCS Num field
- #########################################################################
- TASK RecordGetAboutThisMacintosh(pPhysicalRAM := 1, pLogicalRAM := 1, pLargestUnusedBlock := 1,pSystemSize := 1, pAppName := global gApptitle)
- begin
- global kTCSetMemorySize, kTCTypeConfig;
- returnVal := 0;
- if not (_MemoryMonitor('Initialize', {1})[1])
- begin
- MemoryInfo := _MemoryMonitor('GetAboutThisMacintosh');
- if(MemoryInfo[1] <> 0)
- begin
- println "Problem making call to GetAboutThisMacintosh()"; # print error
- println "Error ", MemoryInfo[1], ". ", MemoryInfo[3] ;
- end;
- else
- begin
- returnVal := 1;
-
- ## PhysicalRAM
- if(pPhysicalRAM)
- begin
- TCSStart({1,kTCSetMemorySize, kTCTypeConfig}, "PhysicalRAM", "Memory Monitor");
- PhysicalRAM := MemoryInfo[2][1];
- TCSEnd({1,kTCSetMemorySize, kTCTypeConfig}, returnVal,,PhysicalRAM);
- end;
-
- ## LogicalRAM
- if(pLogicalRAM)
- begin
- TCSStart({2,kTCSetMemorySize, kTCTypeConfig}, "LogicalRAM", "Memory Monitor");
- LogicalRAM := MemoryInfo[2][2];
- TCSEnd({2,kTCSetMemorySize, kTCTypeConfig}, returnVal,,LogicalRAM);
- end;
-
- ## Largest Unused Block
- if(pLargestUnusedBlock)
- begin
- TCSStart({3,kTCSetMemorySize, kTCTypeConfig}, "Largest Unused Block", "Memory Monitor");
- LargestUnusedBlock := MemoryInfo[2][3];
- TCSEnd({3,kTCSetMemorySize, kTCTypeConfig}, returnVal,,LargestUnusedBlock);
- end;
-
- ## uncomment when Memory Monitor bug is fixed!
- (*
- ## System Size
- if(pSystemSize)
- begin
- TCSStart({4,kTCSetMemorySize, kTCTypeConfig}, "System Size", "Memory Monitor");
- Processes := MemoryInfo[2][4];
- systemSize := Assoc('System', Processes);
- TCSEnd({4,kTCSetMemorySize, kTCTypeConfig}, returnVal,,,systemSize);
- end;
- *)
- ## App Size
- if pAppName
- begin
- if (pAppName <> 'Unknown')
- begin
- TCSStart({5,kTCSetMemorySize, kTCTypeConfig }, "Application memory usage");
- Processes := MemoryInfo[2][4];
- AppSize := Assoc("{pAppName}", Processes);
- TCSEnd({5,kTCSetMemorySize, kTCTypeConfig },returnVal,,AppSize, pAppName);
- end;
- end;
- end;
-
- _MemoryMonitor('Quit');
-
- end;
- return (returnval);
- end;
-
- ##################################################################################
- # FileShare()
- #=======================================================================
- # Author: GS
- # Description: Checks to see if fileshare was installed and whether its switched on.
- #
- # Parameters: None
- # Returns: On := 1
- # Off := 0
- # not Avail:= -1
- # GestaltError
- #=======================================================================
- # History:
- #
- ##################################################################################
- TASK FileShare()
- begin
- if(OnTargetInit())
- begin
- theResult := _OnTarget( 'FileShare' )[2];
-
- if(theResult = 0)
- retVal := {0, "FileSharing is available but NOT ENABLED"};
-
- else if(theResult = 1)
- retVal := {1, "FileSharing is ON"};
-
- else if(theResult = 2)
- retVal := {-1, "FileSharing is not available on this machine"};
-
- else
- retVal := {-1, "Error checking status of Filesharing"};
-
- _OnTarget('Quit');
- end;
- else
- retVal := {-2,"We Don't know, can't launch OnTarget to find out"};
-
- return(retVal);
- end;
-
- ##################################################################################
- # MachineState()
- #=======================================================================
- # Author: GS
- # Description: Returns a list of information concerning the state of the target
- # machine.
- #
- # Parameters: None
- # Returns: Gestalt Info
- #=======================================================================
- # History:
- # KTA 8/3/93 Rewrote - returns instead of prints info
- # KTA 12/3/93 Return logical and Physical memory in Bytes.
- # KTA 3/23/94 Removed System Arch
- # ML 9/21/94 VU 2.1 gestalt support
- # ML 11/29/94 Added Exception Handling support
- # KTA 1/11/95 Removed gestalt support for VU 2.0.1 (two shorts)
- # KTA 1/16/95 Added support for OSVersion and ROMBuild.
- # KTA 1/16/95 Added pUseXTools
- # KTA 2/16/95 Readded MonitorInfo
- ##################################################################################
- TASK MachineState(printMachineState := 0, pUseXTools := 1)
- begin
- try
- begin
- match[system v:?OSVersion];
- match([target t:?TargetName s:?ScreenInfo]);
- end;
- catch theError
- ExceptionDispatcher(theError);
-
- CPUType := { "CPUType", GestaltProcessorType()};
- MMUType := { "MMUType", GestaltMMUType()};
- FPUType := { "FPUType", GestaltFPUType()};
- MachineType := { "MachineType", GestaltMachineType()};
-
- TargetsName := { "TargetName", TargetName};
- AddrMode := { "AddrMode", Check32Bit()[1]};
-
- ## logical Mem
- logMem := (_Gestalt('lram')[2]);
- LogicalMem := { "LogicalMem",logMem };
-
- ## Physical Mem
- PhysMem := (_Gestalt('ram ')[2]);
- PhysicalMem := { "PhysicalMem",PhysMem};
-
- VM := { "VM", CheckVM()[1]};
- if(pUseXTools)
- begin
- FileSharing := { "FileShare", FileShare()[1]}; # Requires OnTarget
- ROMBuild := { "ROMBuild", GetROMBuild()}; # Requires MemoryMonitor 1.0.5 or greater
- end;
- else
- begin
- FileSharing := { "FileShare", -2}; # We don't know
- ROMBuild := { "ROMBuild", ''}; # We don't know
- end;
-
- Caches := { "Cache", CheckCache()[1]};
- OSVersion := { "OSVersion", OSVersion};
-
- MonitorInfoList := {};
- for i := 1 to Card (ScreenInfo)
- begin
- BitDepthScreenRectList := {ScreenInfo[i].p, ScreenInfo[i].r};
- MonitorInfoList[i] := BitDepthScreenRectList;
- end;
- MonitorInfo := { "MonitorInfo", MonitorInfoList};
-
- returnVal := {CPUType, MMUType, FPUType, MachineType, TargetsName, AddrMode, LogicalMem, PhysicalMem, VM, FileSharing, Caches, MonitorInfo,OSVersion,ROMBuild };
- if (printMachineState)
- begin
- for each item in returnVal
- println item[1], ": ",item[2];
- end;
-
- return(returnVal);
- end;
-
- ##################################################################################
- # CheckCache()
- #=======================================================================
- # Author: GS
- # Description: Checks to see if caching is available and turned on, and returns
- # a value.
- #
- # Parameters: None
- # Returns: On := 1
- # Off := 0
- # not Avail := -1
- # GestaltError
- #=======================================================================
- # History:
- #
- ##################################################################################
- TASK CheckCache()
- begin
- if (GestaltProcessorType() = '68040')
- begin
- if(OnTargetInit())
- begin
- toolRes := _OnTarget( 'CacheTest' )[2];
-
- if(toolRes = 1)
- retVal := {1, "040 Caches are ON"};
-
- if(toolRes = 2)
- retVal := {-1, "This isn't an '040, caching unavailable"};
-
- if(toolRes = 0)
- retVal := {0, "040 Caches are OFF"};
-
- _OnTarget('Quit');
- end;
- else
- retVal := {-2,"We Don't know, can't launch OnTarget to find out"};
-
- end;
- else
- retVal := {-1, "This isn't an '040, caching unavailable"};
-
- return retVal;
- end;
-
- #########################################################################
- # RecordMonitorInfo(pReturnList)
- #========================================================================
- # Author: ML
- # Description: Makes the calls to create TCSes which record the
- # target monitors' bit depth and coordinates
- # Returns: {list} - list of monitor info {{bit depth,{l,t,r,b}}}
- # 0 - unsuccessful
- # Examples: RecordMonitorInfo();
- # Assumptions:
- #========================================================================
- # History:
- # ML 3/15/94 Created
- # KTA 1/11/95 Changed it so doesn't call MachineState() and simplified.
- #########################################################################
- TASK RecordMonitorInfo()
- begin
- ScreenDesc := _collect([screen]);
- MonitorCount := Card (ScreenDesc);
- for i := 1 to MonitorCount
- begin
- ScreenRect := ScreenDesc[i].r;
- TCSStart ({1, "Monitors", global kTCTypeConfig},"Monitor Info");
- TCSEnd({ 1, "Monitors", global kTCTypeConfig},1,,ScreenDesc[i].p, "Screen ∂# '{i}' - {ScreenRect}");
- end;
- end;
-
- #########################################################################
- # ProfileApplication()
- #========================================================================
- #
- # Author: ML
- #
- # Description: Determines app process info, version info and
- # whether it is FAT, native, or 68k.
- # Parameters: appname - name of app in process list
- # Returns: none
- # Examples: AppInfo()
- # Notes: Requires Memory Monitor and Filetool on target and
- # corresponding libs on the host.
- #========================================================================
- # History:
- # ML 3/17/94 Created
- # ML 5/10/94 Check for modal before Profiling application
- # ML 9/21/94 Check globals gAddSuiteInfoFieldsRE and gAdditionalSuiteInfoFT
- # before resetting
- # ML 11/29/94 Added Exception Handling support
- # ML 12/12/94 removed gTestCaseLoggingMethod,
- # revised filetool calls to _Filetool
- # removed support for additional suite fields in filetool
- #########################################################################
- task ProfileApplication (appname:= global gApptitle)
- begin
- global gAppVersion;
-
- if not (_matchBoolean ([window o:1 s: dialog]!))
- begin
-
- RecordGetAboutThisMacintosh(0,0,,,appname);
-
- if not (_MemoryMonitor('Initialize', {1})[1]) # if memory monitor initializes ok
- begin
- ProcessInfo:= _MemoryMonitor('GetProcessInfo', {appname}); # get info on appname
- ProcessPath:= ProcessInfo[2][7]; # path to appname's location
- _MemoryMonitor('Quit');
- if ProcessPath <> 'undefined' # if valid path to appname
- begin
- if not (_FileTool('Initialize', {1})[1]) # if FileTool initializes ok on target
- begin
- OnPowerPC := IsPowerPC(); # what kind of Mac are we running on
- VersionInfoList:= _FileTool('ReadVersion',{ProcessPath,1}); # get appname's version info
- AppVersSaveOff := gAppVersion;
- gAppVersion:= VersionInfoList[2][1]; # get the version
- println ("The actual version of {appname} running is {gAppVersion}");
- cfrgExists:= _FileTool('ResourceExists',{ProcessPath, 'cfrg', 0}); # does appname have a code fragment resource
- codeExists:= _FileTool('ResourceExists',{ProcessPath, 'CODE', 0}); # does appname have a code resource
- _FileTool( "Quit" ); # quit FileTool on the target
-
- if cfrgExists[2] # if appname has a cfrg
- begin
- if codeExists[2] # if it also has a CODE
- begin
- AppType:= "Fat";
- print ("{appname} is a FAT application");
- if OnPowerPC
- println (" running NATIVE.");
- else
- println (" running 68K.");
- end; # if codeExists
- else # if not codeExists
- begin
- AppType:= "PPC";
- println ("{appname} is a purely native application running NATIVE.");
- end; # not codeExists
- end; # if cfrgExists
- else # if not cfrgExists
- begin
- AppType:= "68k";
- print ("{appname} is a 68k application");
- if OnPowerPC
- println (" running EMULATED.");
- else
- println (".");
- end; # if not cfrgExists
- end; # if FileTool initializes ok
- end; # if valid path to appname
- end; # if memory monitor initializes ok
-
- if not global gAddSuiteInfoFieldsRE
- global gAddSuiteInfoFieldsRE := {};
-
- if global gAppTitleSaveOff <> gApptitle # if gAppTitle has been modified after launch
- gAddSuiteInfoFieldsRE := gAddSuiteInfoFieldsRE + {{ 'AppName', gAppTitle}};
-
- if AppVersSaveOff <> gAppVersion # if gAppVersion has been modified after launch
- gAddSuiteInfoFieldsRE := gAddSuiteInfoFieldsRE + {{ 'AppVers', gAppVersion}};
-
- if AppType
- gAddSuiteInfoFieldsRE := gAddSuiteInfoFieldsRE + {{ 'CodeType', AppType}};
-
- end; # if not match [window o:1 s: dialog]!
- else
- println "WARNING - Modal dialog present - not profiling application";
- end; # task ProfileApplication
-
-
- #########################################################################
- # GetROMBuild()
- #========================================================================
- # Description: Reads the target ROM and returns the build of the ROM.
- # Note: this is not the ROM Version as returned by Gestalt.
- # Reads a short at offset 18 from ROM base @ 0x2AE+Ox12, then
- # returns the formatted results.
- # Parameters: none
- # Returns: Formated string which is the build of the ROM.
- # Examples: GetROMBuild()
- # Notes: Requires Memory Monitor version 1.0.5 or greater (reading
- # ROM addresses was added to this build)
- #========================================================================
- # History:
- # KTA 1/31/95 Print error message when old version of MemoryMonitor
- # ML 2/15/95 if fail, return string instead of undefined.
- #########################################################################
- task GetROMBuild()
- Begin
- ### Read Pointer to ROM base from low mem global @ 0x2AE
- x := _MemoryMonitor('ReadBytes',{ {0, 686}, 4 });
- if (x[1] = 0)
- begin
- ByteList := x[2];
- ROMBaseAddr := { (ByteList[1] << 8) + ByteList[2], # High word
- (ByteList[3] << 8) + ByteList[4] }; # Low word
-
- ### Read Rom build directly from ROM,
- ### read a short at offset 18 from ROM base @ 0x2AE+Ox12
- ROMBuildAddr := { ROMBaseAddr[1], ROMBaseAddr[2] + 18 };
- x := _MemoryMonitor('ReadBytes',{ ROMBuildAddr, 2 });
- _MemoryMonitor('Quit');
-
- if (x[1] = 0)
- begin
- ByteList := x[2];
- ROMBuild := (ByteList[1] << 8) + ByteList[2];
- BuildStr := NumToStr( ROMBuild, 16 ); # Get Hex string of ROM build
- BuildStr := StringAfterChar(BuildStr, 'x'); # Sring the 0x from buildstring
-
- if BuildStr[1] ~= /[0-9]/
- dot := '.'; #e.g. 2.1A2 (0x21A2)
- else
- dot := ''; #e.g. D11C4 (0xDBC4)
-
- PadCount := 4 - card BuildStr;
-
- for i := 1 to PadCount #pad to 4 hex digits
- BuildStr := '0' + BuildStr;
-
- BuildStr := BuildStr[1] + dot + "{StrToNum( '0x' + BuildStr[2] )}" +
- BuildStr[3] + "{StrToNum( '0x' + BuildStr[4] )}";
-
- return BuildStr;
- end;
- else
- return "ERROR: MemMon problem";
-
- end;
- else if(x[1] = 3)
- begin
- println "!@#$% ∂'WARNING: You may be running an old version of the Memory Monitor ( use version 1.0.5 or greater to read the ROMBuild )";
- return 'ERROR: Old MemoryMon';
- end;
- else
- return "ERROR: MemMon problem";
- end;
-
- #########################################################################
- # IsPowerPC()
- #=======================================================================
- # Author: KTA
- # Description: Makes a call to ProcessorType() to determine if the
- # target system is PowerPC or not
- # Parameters: none
- # Returns: 0 - not PowerPC
- # 1 - PowerPC
- #=======================================================================
- # History:
- # KTA 12/01/93 Created
- ########################################################################
- TASK IsPowerPC()
- begin
- returnVal := 0;
- sysa := GestaltSystemArchitecture();
- if(sysa = 2)
- returnVal := 1;
- return(returnVal);
- end;
-
- #########################################################################
- # IsSystem7()
- #=======================================================================
- # Author: KTA
- # Description: Makes a gestalt call to to determine if the
- # target system is system 7.0 or greater.
- # Parameters: none
- # Returns: 0 - not system 7.0 or greater
- # 1 - system 7.0 or greater
- # Note: the global gIsSys7 will also be set as a side effect
- # of calling this task.
- #=======================================================================
- # History:
- # KTA 4/11/95 Created
- ########################################################################
- TASK IsSystem7()
- begin
- SystemCheck := _Gestalt('sysv');
- if (SystemCheck[1] = 0)
- begin
- if (SystemCheck[2] >= 1792) # 1792 is 0700 in Hex for system 7.0
- Global gIsSys7 := 1; # System7 features are available
- else
- Global gIsSys7 := 0; # System7 features are not available
- end;
- return(gIsSys7);
- end;